Service-now Integration with Google Assistant

Integration between Google Assistant and Servicenow tool is instructing google assistant application to perform certain task in service-now tool for us through our voice command.


For example we can give command "open incident" to google assistant application and it will create an incident in servicenow tool. After creating incident in service-now tool, service-now tool will give the response to google assistant application.


Image 333


We are going to follow the steps below:

   1.Create Google Assistant Project i.e. Call Servicenow

   2.Create one Invocation Name i.e. Mr. Now

   3.Create Intent i.e. create incident

   4.Create Training Phrases for Intent i.e. create incident and open incident

   5.Create Entities for Intent i.e option and incident

   6.Create scripted Rest scripted webservice in Servicenow i.e. googleassistant

   7.Enable Webhook in Fulfilment and user the scripted servicenow webservice for communication.


Google Assistant Integration with Service-now - Youtube Video Link


Lets go through steps:


1. First Go to --> Google Assistant Console

2.Search "Google Assistant Console" in google


Image 1

3.Click on "Google Assistant | Google Developers"


Image 2


4.Click on "Go to Actions Console"


Image 3


5.Click on "New Project"

6.Agree  the Terms and Services

7.Give the Project Name and select the Language and Country


Image 4


8.Click on "Assistant SDK" 


Image 5


9. Click on "OK"


Image 6


10. Now you can see all the options on the Action Console like 

     a.Overview

     b.Develop

     c.Test

     d.Deploy

     e.Analytics


Image 7


11.Click on Develop Tab and give the Display Name and select Google Assistant Voice and SAVE.


Image 8


12. Go to "Action" and Click on Get Started


Image 9


13. Click on "Build", It will go to Dialog Flow


Image 10


14. Please select Country and accept Terms and Services.


Image 111


15.You will get Dialog Flow Window, please give the name as "Call-Servicenow" and Click on Create


Image 11


16. Now Create Intent


Image 12 Image 14


17.After Creating Intent as "create incident", click on Intent Menu, you will get the new intent in the list (Dont forgot to Save)


Image 15


18. Scroll Down and Select the "Training Phrases",  Add Training Phrases (Dont forgot to Save)


Image 23


19. Add the Training Phrases (Dont forgot to Save)


Image 27


20. Check the Training Phrases


Image 16


21.Create Entities like  what I have created like option and incident (Dont forgot to Save)


Image 18 Image 19 Image 20 Image 21


22. Go to Intent list and selct the intent "create incident" and go to created Training Phrases


Image 22


23. Select "open" from Training Phrases and select the option as entity

24. Select "incident" from Training Phrases and select the incident as entity


Image 24 Image 222


25. Go to "Action and Parameters" and select as "Required"


Image 25 Image 26


26. Now go to Fullfillment of the created intent and enable it.

Enable Webhook call for this intent.


Image 34 Image 35


26.1 Go to your servicenow instance and create one scripted webservice as per below screen shots and scripted


Image s1 Image s2 Image s3


Please refer the below script:

(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {


    var responseMsg = response.getStreamWriter(),

        responseType = {};

    var x = request.body.data;

    gs.info("request data Pavan" + x);


    var context = '';

    var message = '';


    data = {};


  //  if (x.queryResult.intent.displayName == 'open incident') create incident

if (x.queryResult.intent.displayName == 'create incident')

    {


        // var numbers = x.queryResult.parameters.number + "";



        var incidentNumber = "";

        var gr = new GlideRecord("incident");

        gr.initialize();

        gr.short_description = "This is just short description";

        gr.description = "Testing Google Assistance ";

        gr.assigned_to = "5aed35dddb9f00108b8bd1b1ca9619b0";

        var tt = gr.insert();

        gr.addQuery("sys_id", tt);

        gr.query();

        if (gr.next()) {

            incidentNumber = gr.number;

        }


        message = "We have raised an incident " + incidentNumber + " and assigned to " + gr.assigned_to.name;

        context = 'success';


    } else if (x.queryResult.intent.displayName == 'get incident') {


        var tableName = x.queryResult.parameters.ticket + "";

        var ticketNumber = x.queryResult.parameters.ticket_number + "";

        var t = new GlideRecord("" + tableName);


        t.addQuery("number", 'CONTAINS', ticketNumber);


        t.query();


        if (t.next()) {



            message = "We have " + tableName + " with number " + ticketNumber + " and this " + tableName + "is assigned to " + t.assigned_to.name + ". This " + tableName + " having short description as " + t.short_description;

            context = 'success';

            

        } else {

            message = "Sorry , we dont have " + tableName + " with number " + ticketNumber;


            context = 'success';


        }

    }



    responseType['Content-Type'] = 'application/json';


    response.setStatus(200);


    response.setHeaders(responseType);


    var response_body = {


        "fulfillmentText": message,


        "payload": {


            "google": {


                "expectUserResponse": true,


                "richResponse": {


                    "items": [


                        {


                            "simpleResponse": {


                                "textToSpeech": message


                            }


                        }


                    ]


                }


            }


        }



    };


    responseMsg.writeString(global.JSON.stringify(response_body));



})(request, response);


27. Go to Fullfillment section from left side.

Use basic auth for this intent and save it.

Provide the details as per below screen shot.

Please enable the small talk as well.


Image 36 Image 30 Image 31


28. Now you can test using small Talk..if you are getting the response as you have configure in servicenow then you app is on correct track.


Image 333


29. Now Go to "Inegration" menu from left nevigation and click on select the intent and click on "Manage Assistant App"


Image 28 Image 29 Image 38


30. It will redirect to Action Console Again and now go to Test.


Image 39 Image 40 Image 41